package WaiBao;

import java.util.Arrays;

public class ShiSHiJie {
    public static void main(String[] args) {
        String[] name = {"韩愈(班长)", "孙悟空(纪律委员)", "小李(学习委员)", "孙行者(文艺委员)", "孙大圣", "猪八戒", "猪悟能", "沙和尚", "唐僧", "高老庄", "典韦", "徐晃",
                "魏延", "王平", "王朗", "诸葛亮", "诸葛瑾", "小乔", "大乔", "西施", "王昭君", "貂蝉", "赵薇", "赵惊", "李琦", "王部", "李浩晨", "李部",
                "杨幂", "史世杰(学生)"};//考生本人: 史世杰(学生)
        int[] age = {19, 20, 20, 19, 19, 20, 19, 21, 21, 19, 18, 18, 19, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 19, 20, 20, 21, 20};//最后一位：考生年龄:20

        double[] zhao1 = {77, 74, 84, 80, 79, 69, 78, 89, 84, 80, 91, 84, 85, 89, 65, 68, 79, 90, 66, 84, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] zhao2 = {78, 88, 99, 76, 75, 77, 78, 79, 80, 70, 90, 77, 66, 95, 60, 65, 76, 99, 64, 98, 72, 71, 95, 86, 76, 84, 84, 65, 81, 95};
        double[] zhao3 = {84, 76, 84, 85, 77, 66, 78, 69, 80, 80, 93, 87, 85, 65, 85, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 87, 73, 71, 89, 96};


        double geng1;//代表每个学生的总分
        double geng2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            geng1 = zhao1[i] + zhao2[i] +zhao3[i];
//            geng2 = (geng1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + geng1);
//            System.out.println(name[i] + "的平均分为:" + geng2);
//        }


        double bo1 = 0,bo2 = 0;
        double[] Arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            bo1 = zhao1[i] + zhao2[i] + zhao3[i];
//            bo2= (bo1 * 1.0) / 3;
//            Arr[i] = bo2;
//        }
//
//        for (int i = 0; i < Arr.length - 1; i++) {
//            for (int j = 0; j < Arr.length - i - 1; j++) {
//                if (Arr[j] < Arr[j + 1]) {
//                    double tep = Arr[j];
//                    Arr[j] = Arr[j + 1];
//                    Arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Arr[i]);
//        }



        double index1 = 0, index2 = 0, index3 = 0;//计算每门课的平均分
        double demo1 = 0, demo2 = 0, demo3 = 0;//计算每门课标准差
        double hello1 = 0,hello2 = 0, hello3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <zhao1.length; i++) {
            he += zhao1[i];
        }
        index1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + index1);
        double Sum = 0;
        for (int i = 0; i < zhao2.length; i++) {
            Sum += zhao2[i];
        }
        index2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + index2);
        double sum = 0;
        for (int i = 0; i < zhao3.length; i++) {
            sum += zhao3[i];
        }
        index3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + index3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < zhao1.length; i++) {
            c1 += (zhao1[i] - index1) * (zhao1[i] - index1);
        }
        demo1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + demo1);
        for (int i = 0; i < zhao2.length; i++) {
            c2 += (zhao2[i] - index2) * (zhao2[i] - index2);
        }
        demo2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + demo2);

        for (int i = 0; i < zhao3.length; i++) {
            c3 += (zhao3[i] - index3) * (zhao3[i] - index3);
        }
        demo3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + demo3);
////
//
//
        Arrays.sort(zhao1);
        Arrays.sort(zhao2);
        Arrays.sort(zhao3);
        hello1 = (zhao1[14] + zhao2[15]) * 1.0 / 2;
        hello2 = (zhao2[14] + zhao2[15]) * 1.0 / 2;
        hello3 = (zhao3[14] + zhao3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + hello1);
        System.out.println("物理化学的中位数为:" + hello2);
        System.out.println("电子与电工技术的中位数为:" + hello3);
    }
}
